package com.apimanage.gateway.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * IP过滤配置属性类
 * 用于配置IP黑白名单
 */
@Component
@ConfigurationProperties(prefix = "gateway.ip-filter")
public class IpFilterProperties {

    /**
     * 是否启用IP过滤
     */
    private boolean enabled = false;

    /**
     * IP过滤模式：blacklist(黑名单)、whitelist(白名单)
     */
    private String mode = "blacklist";

    /**
     * IP黑名单列表
     */
    private List<String> blacklist = Collections.emptyList();

    /**
     * IP白名单列表
     */
    private List<String> whitelist = Collections.emptyList();

    /**
     * 不需要进行IP过滤的路径
     */
    private List<String> excludePaths = Collections.emptyList();

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public List<String> getBlacklist() {
        return blacklist;
    }

    public void setBlacklist(List<String> blacklist) {
        this.blacklist = blacklist;
    }

    public List<String> getWhitelist() {
        return whitelist;
    }

    public void setWhitelist(List<String> whitelist) {
        this.whitelist = whitelist;
    }

    public List<String> getExcludePaths() {
        return excludePaths;
    }

    public void setExcludePaths(List<String> excludePaths) {
        this.excludePaths = excludePaths;
    }
}